package org.jivesoftware.smack;

import com.easemob.util.EMLog;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.lang.reflect.Constructor;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.net.SocketFactory;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import org.apache.harmony.javax.security.auth.callback.Callback;
import org.apache.harmony.javax.security.auth.callback.CallbackHandler;
import org.apache.harmony.javax.security.auth.callback.PasswordCallback;
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
import org.jivesoftware.smack.debugger.SmackDebugger;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.packet.XMPPError.Condition;
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.dns.HostAddress;

public class XMPPConnection extends Connection
{
  private static final String TAG = "sxmppcon";
  Socket socket;
  String connectionID = null;
  private String user = null;
  private boolean connected = false;
  private volatile boolean socketClosed = false;
  private boolean authenticated = false;
  private boolean wasAuthenticated = false;
  private boolean anonymous = false;
  private boolean usingTLS = false;
  private ParsingExceptionCallback parsingExceptionCallback = SmackConfiguration.getDefaultParsingExceptionCallback();
  PacketWriter packetWriter;
  PacketReader packetReader;
  Roster roster = null;
  private Collection<String> compressionMethods;
  private boolean serverAckdCompression = false;
  private Object mutex = new Object();

  public XMPPConnection(String paramString, CallbackHandler paramCallbackHandler)
  {
    super(new ConnectionConfiguration(paramString));
    this.config.setCompressionEnabled(false);
    this.config.setSASLAuthenticationEnabled(true);
    this.config.setDebuggerEnabled(DEBUG_ENABLED);
    this.config.setCallbackHandler(paramCallbackHandler);
  }

  public XMPPConnection(String paramString)
  {
    super(new ConnectionConfiguration(paramString));
    this.config.setCompressionEnabled(false);
    this.config.setSASLAuthenticationEnabled(true);
    this.config.setDebuggerEnabled(DEBUG_ENABLED);
  }

  public XMPPConnection(ConnectionConfiguration paramConnectionConfiguration)
  {
    super(paramConnectionConfiguration);
  }

  public XMPPConnection(ConnectionConfiguration paramConnectionConfiguration, CallbackHandler paramCallbackHandler)
  {
    super(paramConnectionConfiguration);
    paramConnectionConfiguration.setCallbackHandler(paramCallbackHandler);
  }

  public String getConnectionID()
  {
    if (!isConnected())
      return null;
    return this.connectionID;
  }

  public String getUser()
  {
    if (!isAuthenticated())
      return null;
    return this.user;
  }

  public void setParsingExceptionCallback(ParsingExceptionCallback paramParsingExceptionCallback)
  {
    this.parsingExceptionCallback = paramParsingExceptionCallback;
  }

  public ParsingExceptionCallback getParsingExceptionCallback()
  {
    return this.parsingExceptionCallback;
  }

  public void login(String paramString1, String paramString2, String paramString3)
    throws XMPPException
  {
    if (!isConnected())
      throw new XMPPException("Not connected to server.");
    if (this.authenticated)
      throw new XMPPException("Already logged in to server.");
    paramString1 = paramString1.toLowerCase().trim();
    if (this.config.isCompressionEnabled())
      useCompression();
    String str;
    if ((this.config.isSASLAuthenticationEnabled()) && (this.saslAuthentication.hasNonAnonymousAuthentication()))
    {
      if (paramString2 != null)
        str = this.saslAuthentication.authenticate(paramString1, paramString2, paramString3);
      else
        str = this.saslAuthentication.authenticate(paramString1, paramString3, this.config.getCallbackHandler());
    }
    else
      str = new NonSASLAuthentication(this).authenticate(paramString1, paramString2, paramString3);
    if (str != null)
    {
      this.user = str;
      this.config.setServiceName(StringUtils.parseServer(str));
    }
    else
    {
      this.user = (paramString1 + "@" + getServiceName());
      if (paramString3 != null)
        this.user = (this.user + "/" + paramString3);
    }
    this.authenticated = true;
    this.anonymous = false;
    if (this.roster == null)
      if (this.rosterStorage == null)
        this.roster = new Roster(this);
      else
        this.roster = new Roster(this, this.rosterStorage);
    if (this.config.isRosterLoadedAtLogin())
      this.roster.reload();
    if (this.config.isSendPresence())
      this.packetWriter.sendPacket(new Presence(Presence.Type.available));
    this.config.setLoginInfo(paramString1, paramString2, paramString3);
    if ((this.config.isDebuggerEnabled()) && (this.debugger != null))
      this.debugger.userHasLogged(this.user);
  }

  public synchronized void loginAnonymously()
    throws XMPPException
  {
    if (!isConnected())
      throw new IllegalStateException("Not connected to server.");
    if (this.authenticated)
      throw new IllegalStateException("Already logged in to server.");
    String str;
    if ((this.config.isSASLAuthenticationEnabled()) && (this.saslAuthentication.hasAnonymousAuthentication()))
      str = this.saslAuthentication.authenticateAnonymously();
    else
      str = new NonSASLAuthentication(this).authenticateAnonymously();
    this.user = str;
    this.config.setServiceName(StringUtils.parseServer(str));
    if (this.config.isCompressionEnabled())
      useCompression();
    this.packetWriter.sendPacket(new Presence(Presence.Type.available));
    this.authenticated = true;
    this.anonymous = true;
    if ((this.config.isDebuggerEnabled()) && (this.debugger != null))
      this.debugger.userHasLogged(this.user);
  }

  public Roster getRosterWithoutLoad()
  {
    synchronized (this)
    {
      if ((!isAuthenticated()) || (isAnonymous()))
      {
        if (this.roster == null)
          if (this.rosterStorage != null)
            this.roster = new Roster(this, this.rosterStorage);
          else
            this.roster = new Roster(this);
        return this.roster;
      }
    }
    return this.roster;
  }

  public Roster getRoster()
  {
    synchronized (this)
    {
      if ((!isAuthenticated()) || (isAnonymous()))
      {
        if (this.roster == null)
          if (this.rosterStorage != null)
            this.roster = new Roster(this, this.rosterStorage);
          else
            this.roster = new Roster(this);
        return this.roster;
      }
    }
    if ((!this.config.isRosterLoadedAtLogin()) && (!this.roster.rosterInitialized))
      this.roster.reload();
    if (!this.roster.rosterInitialized)
      try
      {
        synchronized (this.roster)
        {
          long l1 = SmackConfiguration.getPacketReplyTimeout();
          long l3;
          for (long l2 = System.currentTimeMillis(); !this.roster.rosterInitialized; l2 = l3)
          {
            if (l1 <= 0L)
              break;
            this.roster.wait(l1);
            l3 = System.currentTimeMillis();
            l1 -= l3 - l2;
          }
        }
      }
      catch (InterruptedException localInterruptedException)
      {
      }
    return this.roster;
  }

  public boolean isConnected()
  {
    return this.connected;
  }

  public boolean isSecureConnection()
  {
    return isUsingTLS();
  }

  public boolean isSocketClosed()
  {
    return this.socketClosed;
  }

  public boolean isAuthenticated()
  {
    return this.authenticated;
  }

  public boolean isAnonymous()
  {
    return this.anonymous;
  }

  public void release()
  {
    PacketReader localPacketReader = this.packetReader;
    PacketWriter localPacketWriter = this.packetWriter;
    if ((localPacketReader == null) || (localPacketWriter == null))
      return;
    shutdown(new Presence(Presence.Type.unavailable));
    this.released = true;
    this.chatManager = null;
    this.wasAuthenticated = false;
  }

  protected void shutdown(Presence paramPresence)
  {
    EMLog.d("sxmppcon", "(" + hashCode() + ") " + "shutdown");
    if (this.packetWriter != null)
      this.packetWriter.sendPacket(paramPresence);
    setWasAuthenticated(this.authenticated);
    this.authenticated = false;
    if (this.packetReader != null)
      this.packetReader.shutdown();
    if (this.packetWriter != null)
      this.packetWriter.shutdown();
    try
    {
      Thread.sleep(150L);
    }
    catch (Exception localException1)
    {
    }
    this.socketClosed = true;
    if (this.socket != null)
      EMLog.d("sxmppcon", "trying to close the socket : " + this.socket);
    try
    {
      this.socket.close();
    }
    catch (Exception localException2)
    {
      localException2.printStackTrace();
    }
    EMLog.d("sxmppcon", "(" + hashCode() + ") " + "socket was closed");
    this.connected = false;
    this.reader = null;
    this.writer = null;
    this.saslAuthentication.init();
    cancelAllWaiting();
  }

  public void disconnect(Presence paramPresence)
  {
    EMLog.i("sxmppcon", "enter disconnect (" + hashCode() + ")");
    PacketReader localPacketReader = this.packetReader;
    PacketWriter localPacketWriter = this.packetWriter;
    if ((localPacketReader == null) || (localPacketWriter == null))
      return;
    this.wasAuthenticated = false;
    shutdown(paramPresence);
    EMLog.i("sxmppcon", "shutdown was called");
    this.chatManager = null;
  }

  public void sendPacket(Packet paramPacket)
    throws IllegalStateException
  {
    if (!isConnected())
      throw new IllegalStateException("Not connected to server.");
    if (paramPacket == null)
      throw new NullPointerException("Packet is null.");
    this.packetWriter.sendPacket(paramPacket);
  }

  public void addPacketWriterInterceptor(PacketInterceptor paramPacketInterceptor, PacketFilter paramPacketFilter)
  {
    addPacketInterceptor(paramPacketInterceptor, paramPacketFilter);
  }

  public void removePacketWriterInterceptor(PacketInterceptor paramPacketInterceptor)
  {
    removePacketInterceptor(paramPacketInterceptor);
  }

  public void addPacketWriterListener(PacketListener paramPacketListener, PacketFilter paramPacketFilter)
  {
    addPacketSendingListener(paramPacketListener, paramPacketFilter);
  }

  public void removePacketWriterListener(PacketListener paramPacketListener)
  {
    removePacketSendingListener(paramPacketListener);
  }

  private void connectUsingConfiguration(ConnectionConfiguration paramConnectionConfiguration)
    throws Exception
  {
    Object localObject1 = null;
    Iterator localIterator1 = paramConnectionConfiguration.getHostAddresses().iterator();
    LinkedList localLinkedList = new LinkedList();
    int i = 0;
    while (localIterator1.hasNext())
    {
      localObject1 = null;
      HostAddress localHostAddress = (HostAddress)localIterator1.next();
      String str = localHostAddress.getFQDN();
      int j = localHostAddress.getPort();
      EMLog.d("sxmppcon", "try to connect to host : " + str + " port : " + j);
      try
      {
        if (paramConnectionConfiguration.getSocketFactory() == null)
          this.socket = new Socket(str, j);
        else
          this.socket = paramConnectionConfiguration.getSocketFactory().createSocket(str, j);
        EMLog.d("sxmppcon", "open a new socket : " + this.socket);
      }
      catch (UnknownHostException localUnknownHostException)
      {
        localObject1 = localUnknownHostException;
      }
      catch (IOException localIOException)
      {
        localObject1 = localIOException;
      }
      if (localObject1 == null)
      {
        paramConnectionConfiguration.setUsedHostAddress(localHostAddress);
        break;
      }
      localHostAddress.setException(localObject1);
      localLinkedList.add(localHostAddress);
      if (!localIterator1.hasNext())
      {
        StringBuilder localStringBuilder = new StringBuilder();
        Iterator localIterator2 = localLinkedList.iterator();
        Object localObject2;
        while (localIterator2.hasNext())
        {
          localObject2 = (HostAddress)localIterator2.next();
          localStringBuilder.append(((HostAddress)localObject2).getErrorMessage());
          localStringBuilder.append("; ");
        }
        if (localObject1 != null)
          throw localObject1;
        if (i != 0)
          localObject2 = new XMPPError(XMPPError.Condition.remote_server_error);
        else
          localObject2 = new XMPPError(XMPPError.Condition.remote_server_timeout);
        throw new XMPPException(localStringBuilder.toString(), (XMPPError)localObject2, localObject1);
      }
    }
    this.socketClosed = false;
    initConnection();
  }

  private void initConnection()
    throws XMPPException
  {
    int i = (this.packetReader != null) && (this.packetWriter != null) ? 0 : 1;
    this.compressionHandler = null;
    this.serverAckdCompression = false;
    initReaderAndWriter();
    try
    {
      if (i != 0)
      {
        this.packetWriter = new PacketWriter(this);
        this.packetReader = new PacketReader(this);
        if (this.config.isDebuggerEnabled())
        {
          addPacketListener(this.debugger.getReaderListener(), null);
          if (this.debugger.getWriterListener() != null)
            addPacketSendingListener(this.debugger.getWriterListener(), null);
        }
      }
      else
      {
        this.packetWriter.init();
        this.packetReader.init();
      }
      this.packetWriter.startup();
      this.packetReader.startup();
      this.connected = true;
      if (i != 0)
      {
        Iterator localIterator = getConnectionCreationListeners().iterator();
        while (localIterator.hasNext())
        {
          ConnectionCreationListener localConnectionCreationListener = (ConnectionCreationListener)localIterator.next();
          localConnectionCreationListener.connectionCreated(this);
        }
      }
    }
    catch (XMPPException localXMPPException)
    {
      EMLog.d("sxmppcon", "initconnection exception:" + localXMPPException.toString());
      if (this.packetWriter != null)
      {
        try
        {
          this.packetWriter.shutdown();
        }
        catch (Throwable localThrowable1)
        {
        }
        this.packetWriter = null;
      }
      if (this.packetReader != null)
      {
        try
        {
          this.packetReader.shutdown();
        }
        catch (Throwable localThrowable2)
        {
        }
        this.packetReader = null;
      }
      if (this.reader != null)
      {
        try
        {
          this.reader.close();
        }
        catch (Throwable localThrowable3)
        {
        }
        this.reader = null;
      }
      if (this.writer != null)
      {
        try
        {
          this.writer.close();
        }
        catch (Throwable localThrowable4)
        {
        }
        this.writer = null;
      }
      if (this.socket != null)
      {
        try
        {
          this.socket.close();
        }
        catch (Exception localException)
        {
        }
        this.socket = null;
      }
      setWasAuthenticated(this.authenticated);
      this.chatManager = null;
      this.authenticated = false;
      this.connected = false;
      throw localXMPPException;
    }
  }

  private void initReaderAndWriter()
    throws XMPPException
  {
    try
    {
      if (this.compressionHandler == null)
      {
        this.reader = new BufferedReader(new InputStreamReader(this.socket.getInputStream(), "UTF-8"));
        this.writer = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream(), "UTF-8"));
      }
      else
      {
        try
        {
          OutputStream localOutputStream = this.compressionHandler.getOutputStream(this.socket.getOutputStream());
          this.writer = new BufferedWriter(new OutputStreamWriter(localOutputStream, "UTF-8"));
          InputStream localInputStream = this.compressionHandler.getInputStream(this.socket.getInputStream());
          this.reader = new BufferedReader(new InputStreamReader(localInputStream, "UTF-8"));
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
          this.compressionHandler = null;
          this.reader = new BufferedReader(new InputStreamReader(this.socket.getInputStream(), "UTF-8"));
          this.writer = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream(), "UTF-8"));
        }
      }
    }
    catch (IOException localIOException)
    {
      throw new XMPPException("XMPPError establishing connection with server.", new XMPPError(XMPPError.Condition.remote_server_error, "XMPPError establishing connection with server."), localIOException);
    }
    initDebugger();
  }

  public boolean isUsingTLS()
  {
    return this.usingTLS;
  }

  void startTLSReceived(boolean paramBoolean)
  {
    if ((paramBoolean) && (this.config.getSecurityMode() == ConnectionConfiguration.SecurityMode.disabled))
    {
      notifyConnectionError(new IllegalStateException("TLS required by server but not allowed by connection configuration"));
      return;
    }
    if (this.config.getSecurityMode() == ConnectionConfiguration.SecurityMode.disabled)
      return;
    try
    {
      this.writer.write("<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>");
      this.writer.flush();
    }
    catch (IOException localIOException)
    {
      notifyConnectionError(localIOException);
    }
  }

  void proceedTLSReceived()
    throws Exception
  {
    SSLContext localSSLContext = this.config.getCustomSSLContext();
    KeyStore localKeyStore = null;
    KeyManager[] arrayOfKeyManager = null;
    PasswordCallback localPasswordCallback = null;
    if (this.config.getCallbackHandler() == null)
    {
      localKeyStore = null;
    }
    else if (localSSLContext == null)
    {
      if (this.config.getKeystoreType().equals("NONE"))
      {
        localKeyStore = null;
        localPasswordCallback = null;
      }
      else if (this.config.getKeystoreType().equals("PKCS11"))
      {
        try
        {
          Constructor localConstructor = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(new Class[] { InputStream.class });
          String str = "name = SmartCard\nlibrary = " + this.config.getPKCS11Library();
          ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(str.getBytes());
          Provider localProvider = (Provider)localConstructor.newInstance(new Object[] { localByteArrayInputStream });
          Security.addProvider(localProvider);
          localKeyStore = KeyStore.getInstance("PKCS11", localProvider);
          localPasswordCallback = new PasswordCallback("PKCS11 Password: ", false);
          this.config.getCallbackHandler().handle(new Callback[] { localPasswordCallback });
          localKeyStore.load(null, localPasswordCallback.getPassword());
        }
        catch (Exception localException1)
        {
          localKeyStore = null;
          localPasswordCallback = null;
        }
      }
      else if (this.config.getKeystoreType().equals("Apple"))
      {
        localKeyStore = KeyStore.getInstance("KeychainStore", "Apple");
        localKeyStore.load(null, null);
      }
      else
      {
        localKeyStore = KeyStore.getInstance(this.config.getKeystoreType());
        try
        {
          localPasswordCallback = new PasswordCallback("Keystore Password: ", false);
          this.config.getCallbackHandler().handle(new Callback[] { localPasswordCallback });
          localKeyStore.load(new FileInputStream(this.config.getKeystorePath()), localPasswordCallback.getPassword());
        }
        catch (Exception localException2)
        {
          localKeyStore = null;
          localPasswordCallback = null;
        }
      }
      localObject = KeyManagerFactory.getInstance("SunX509");
      try
      {
        if (localPasswordCallback == null)
        {
          ((KeyManagerFactory)localObject).init(localKeyStore, null);
        }
        else
        {
          ((KeyManagerFactory)localObject).init(localKeyStore, localPasswordCallback.getPassword());
          localPasswordCallback.clearPassword();
        }
        arrayOfKeyManager = ((KeyManagerFactory)localObject).getKeyManagers();
      }
      catch (NullPointerException localNullPointerException)
      {
        arrayOfKeyManager = null;
      }
    }
    if (localSSLContext == null)
    {
      localSSLContext = SSLContext.getInstance("TLS");
      localSSLContext.init(arrayOfKeyManager, new TrustManager[] { new ServerTrustManager(getServiceName(), this.config) }, new SecureRandom());
    }
    Object localObject = this.socket;
    this.socket = localSSLContext.getSocketFactory().createSocket((Socket)localObject, ((Socket)localObject).getInetAddress().getHostAddress(), ((Socket)localObject).getPort(), true);
    this.socket.setSoTimeout(0);
    this.socket.setKeepAlive(true);
    initReaderAndWriter();
    ((SSLSocket)this.socket).startHandshake();
    this.usingTLS = true;
    this.packetWriter.setWriter(this.writer);
    this.packetWriter.openStream();
  }

  void setAvailableCompressionMethods(Collection<String> paramCollection)
  {
    this.compressionMethods = paramCollection;
  }

  private XMPPInputOutputStream maybeGetCompressionHandler()
  {
    if (this.compressionMethods != null)
    {
      Iterator localIterator = compressionHandlers.iterator();
      while (localIterator.hasNext())
      {
        XMPPInputOutputStream localXMPPInputOutputStream = (XMPPInputOutputStream)localIterator.next();
        if (localXMPPInputOutputStream.isSupported())
        {
          String str = localXMPPInputOutputStream.getCompressionMethod();
          if (this.compressionMethods.contains(str))
            return localXMPPInputOutputStream;
        }
      }
    }
    return null;
  }

  public boolean isUsingCompression()
  {
    return (this.compressionHandler != null) && (this.serverAckdCompression);
  }

  private boolean useCompression()
    throws XMPPException
  {
    if (this.authenticated)
      throw new IllegalStateException("Compression should be negotiated before authentication.");
    if ((this.compressionHandler = maybeGetCompressionHandler()) != null)
    {
      requestStreamCompression(this.compressionHandler.getCompressionMethod());
      synchronized (this.mutex)
      {
        try
        {
          this.mutex.wait(SmackConfiguration.getPacketReplyTimeout() * 1);
        }
        catch (InterruptedException localInterruptedException)
        {
        }
      }
      if (!this.serverAckdCompression)
        throw new XMPPException("No respnse from server. Compression ACK is not received from server.");
      return isUsingCompression();
    }
    return false;
  }

  private void requestStreamCompression(String paramString)
  {
    try
    {
      this.writer.write("<compress xmlns='http://jabber.org/protocol/compress'>");
      this.writer.write("<method>" + paramString + "</method></compress>");
      this.writer.flush();
    }
    catch (IOException localIOException)
    {
      notifyConnectionError(localIOException);
    }
  }

  void startStreamCompression()
    throws Exception
  {
    this.serverAckdCompression = true;
    initReaderAndWriter();
    this.packetWriter.setWriter(this.writer);
    this.packetWriter.openStream();
    synchronized (this.mutex)
    {
      this.mutex.notify();
    }
  }

  void streamCompressionDenied()
  {
    synchronized (this)
    {
      notify();
    }
  }

  public void connect()
    throws Exception
  {
    if (this.connected)
      return;
    connectUsingConfiguration(this.config);
    if ((this.connected) && (this.wasAuthenticated))
    {
      if (isAnonymous())
        loginAnonymously();
      else
        login(this.config.getUsername(), this.config.getPassword(), this.config.getResource());
      notifyReconnection();
    }
  }

  private void setWasAuthenticated(boolean paramBoolean)
  {
    if (!this.wasAuthenticated)
      this.wasAuthenticated = paramBoolean;
  }

  public void setRosterStorage(RosterStorage paramRosterStorage)
    throws IllegalStateException
  {
    if (this.roster != null)
      throw new IllegalStateException("Roster is already initialized");
    this.rosterStorage = paramRosterStorage;
  }

  void notifyConnectionError(Exception paramException)
  {
    if ((this.packetReader == null) || (this.packetWriter == null))
      return;
    if ((this.packetReader.done) && (this.packetWriter.done))
      return;
    this.packetReader.done = true;
    this.packetWriter.done = true;
    shutdown(new Presence(Presence.Type.unavailable));
    Iterator localIterator = getConnectionListeners().iterator();
    while (localIterator.hasNext())
    {
      ConnectionListener localConnectionListener = (ConnectionListener)localIterator.next();
      try
      {
        localConnectionListener.connectionClosedOnError(paramException);
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }
  }

  protected void notifyReconnection()
  {
    Iterator localIterator = getConnectionListeners().iterator();
    while (localIterator.hasNext())
    {
      ConnectionListener localConnectionListener = (ConnectionListener)localIterator.next();
      try
      {
        localConnectionListener.reconnectionSuccessful();
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }
  }

  public String getIP()
  {
    return this.socket.getInetAddress().getHostAddress();
  }

  private void cancelAllWaiting()
  {
    if (this.mutex != null)
      synchronized (this.mutex)
      {
        this.mutex.notifyAll();
      }
    if (this.packetReader != null)
      synchronized (this.packetReader)
      {
        this.packetReader.notifyAll();
      }
    if (this.saslAuthentication != null)
      synchronized (this.saslAuthentication)
      {
        this.saslAuthentication.notifyAll();
      }
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.XMPPConnection
 * JD-Core Version:    0.6.1
 */